import decimal
import random
import time

import requests

from orderSharing.retailOrderSharing import RetailOrderSharing


class PickUpOrder:

    token = ""
    goodSku = None

    def __init__(self):
        self.retailOrderSharing = RetailOrderSharing()

    # 核算代理分润
    def check_agencys_sharing(self, retailAgentId, retailGoodsSkusPrice, orderId, bindStoreId):
        print("retailAgentId：", retailAgentId)
        self.retailOrderSharing.session.commit()
        retail_agent = self.retailOrderSharing.session.execute(
            "select user_id, parent_id from retail_agents where id = :agentId limit 1",
            params={"agentId": retailAgentId}).first()
        print("retail_agent：", retail_agent)

        self.retailOrderSharing.session.commit()
        change_price = self.retailOrderSharing.session.execute(
            "select change_price from retail_user_frozen_price1_records where user_id = :userId and target_id = :targetId limit 1",
            params={"userId": retail_agent[0], "targetId": orderId}).first()

        if change_price[0] != retailGoodsSkusPrice:
            print("{}营业额计算错误，预期{}，实际{}".format(retail_agent[0], retailGoodsSkusPrice, change_price[0]))

        if retailAgentId == 1:
            print("走没走。。。。")
            return

        if retail_agent[1] > 0:
            self.check_agencys_sharing(retail_agent[1], retailGoodsSkusPrice / 2, orderId, bindStoreId)

    # 核算上级分润
    def check_members_sharing(self, userId, orderId, amount, subRatioList, retailGoodsSkusPrice, retailSets,
                              ordinary, union, partner, crossStore, bindStoreId, unboundStoreId, userLevel, purchaseMethod):
        self.retailOrderSharing.session.commit()
        referee_user = self.retailOrderSharing.session.execute(
            "select referee_user_id from retail_users ru where ru.user_id = :userId limit 1",
            params={"userId": userId}).first()
        print("referee_user：", referee_user)

        if referee_user == None:
            return

        self.retailOrderSharing.session.commit()
        user_vip_level = self.retailOrderSharing.session.execute("select vip_level from retail_vips where user_id = :userId limit 1",
                                              params={"userId": referee_user[0]}).first()
        print("user_vip_level：", user_vip_level)

        # 非跨店
        if crossStore == False:
            if userLevel != None and userLevel[0] == 3:
                if purchaseMethod == 3:
                    print("userLevel：", userLevel)
                    self.retailOrderSharing.session.commit()
                    retail_agent_id = self.retailOrderSharing.session.execute(
                        "select retail_agent_id from retail_stores where id = :storeId limit 1",
                        params={"storeId": bindStoreId}).first()
                    self.check_agencys_sharing(retail_agent_id[0], retailGoodsSkusPrice / 2,
                                               orderId, bindStoreId)

                return

            if user_vip_level == None:
                if ordinary == 1 and referee_user[0] > 0:
                    if union == 1 and partner == 1:
                        self.retailOrderSharing.session.commit()
                        change_credit = self.retailOrderSharing.session.execute(
                            "select change_credit from retail_user_frozen_credit_records where user_id = :userId and target_id = :targetId limit 1",
                            params={"userId": referee_user[0], "targetId": orderId}).first()
                        if change_credit[0] != amount * retailSets[0]:
                            print("{}积分计算错误，预期{}，实际{}".format(referee_user[0], amount * retailSets[0],
                                                              change_credit[0]))

                self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                           retailSets, ordinary + 1, union, partner, crossStore, bindStoreId,
                                           unboundStoreId, userLevel, purchaseMethod)

            else:
                if user_vip_level[0] == 1:
                    if union == 1:
                        if partner == 1:
                            self.retailOrderSharing.session.commit()
                            change_price = self.retailOrderSharing.session.execute(
                                "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                                params={"userId": referee_user[0], "targetId": orderId}).first()
                            if change_price[0] != retailGoodsSkusPrice * subRatioList[0] / 100:
                                print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0],
                                                                    retailGoodsSkusPrice * subRatioList[0] / 100,
                                                                    change_price[0]))

                    self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                               retailSets, ordinary, union + 1, partner, crossStore, bindStoreId,
                                               unboundStoreId, userLevel, purchaseMethod)

                elif user_vip_level[0] == 2:
                    if partner == 1:
                        if union == 1:
                            self.retailOrderSharing.session.commit()
                            change_price = self.retailOrderSharing.session.execute(
                                "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                                params={"userId": referee_user[0], "targetId": orderId}).first()
                            if change_price[0] != retailGoodsSkusPrice * subRatioList[1] / 100:
                                print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0],
                                                                    retailGoodsSkusPrice * subRatioList[1] / 100,
                                                                    change_price[0]))
                        else:
                            if userLevel != None and userLevel[0] == 1:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * subRatioList[1] / 100:
                                    print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * subRatioList[1] / 100, change_price[0]))
                            else:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price4_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * (
                                        subRatioList[1] - subRatioList[0]) / 100:
                                    print("{}分润差额1计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * (
                                                subRatioList[1] - subRatioList[0]) / 100, change_price[0]))

                    self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                               retailSets, ordinary, union, partner + 1, crossStore, bindStoreId,
                                               unboundStoreId, userLevel, purchaseMethod)

                elif user_vip_level[0] == 3:
                    if union == 1 and partner == 1:
                        self.retailOrderSharing.session.commit()
                        change_price = self.retailOrderSharing.session.execute(
                            "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                            params={"userId": referee_user[0], "targetId": orderId}).first()
                        if change_price[0] != retailGoodsSkusPrice * 100 / 100:
                            print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0],
                                                                retailGoodsSkusPrice * 100 / 100,
                                                                change_price[0]))
                    elif union > 1 and partner == 1:
                        if userLevel != None and userLevel[0] == 1:
                            self.retailOrderSharing.session.commit()
                            change_price = self.retailOrderSharing.session.execute(
                                "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                                params={"userId": referee_user[0], "targetId": orderId}).first()
                            if change_price[0] != retailGoodsSkusPrice * 100 / 100:
                                print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * 100 / 100, change_price[0]))
                        else:
                            self.retailOrderSharing.session.commit()
                            change_price = self.retailOrderSharing.session.execute(
                                "select change_price from retail_user_frozen_price4_records where user_id = :userId and target_id = :targetId limit 1",
                                params={"userId": referee_user[0], "targetId": orderId}).first()
                            if change_price[0] != retailGoodsSkusPrice * (
                                    100 - subRatioList[0]) / 100:
                                print("{}分润差额1计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * (
                                            100 - subRatioList[0]) / 100, change_price[0]))
                    elif partner > 1:
                        if userLevel != None:
                            if userLevel[0] == 2:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * 100 / 100:
                                    print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * 100 / 100, change_price[0]))
                            elif userLevel[0] == 1:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price4_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * (
                                        100 - subRatioList[1]) / 100:
                                    print("{}分润差额1计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * (
                                            100 - subRatioList[1]) / 100, change_price[0]))
                        else:
                            if union == 1:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price4_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * (
                                        100 - subRatioList[1]) / 100:
                                    print("{}分润差额1计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * (
                                            100 - subRatioList[1]) / 100, change_price[0]))
                            else:
                                self.retailOrderSharing.session.commit()
                                change_price = self.retailOrderSharing.session.execute(
                                    "select change_price from retail_user_frozen_price5_records where user_id = :userId and target_id = :targetId limit 1",
                                    params={"userId": referee_user[0], "targetId": orderId}).first()
                                if change_price[0] != retailGoodsSkusPrice * (
                                        100 - subRatioList[1]) / 100:
                                    print("{}分润差额2计算错误，预期{}，实际{}".format(referee_user[0], retailGoodsSkusPrice * (
                                                100 - subRatioList[1]) / 100, change_price[0]))

        # 跨店
        else:
            if userLevel != None and userLevel[0] == 3:
                self.retailOrderSharing.session.commit()
                unbound_store_change_price = self.retailOrderSharing.session.execute(
                    "select rufpr.change_price, rs.user_id\
                            from retail_stores rs\
                            inner join retail_user_frozen_price10_records rufpr on rs.user_id = rufpr.user_id\
                            where rs.id = :unboundStoreId and rufpr.target_id = :targetId limit 1",
                    params={"unboundStoreId": unboundStoreId, "targetId": orderId}).first()
                print("unbound_store_change_price：", unbound_store_change_price)
                if unbound_store_change_price[0] != retailGoodsSkusPrice * (retailSets[2] + 10) / 100:
                    print("{}跨店收益计算错误，预期{}，实际{}".format(unbound_store_change_price[1],
                                                        retailGoodsSkusPrice * (retailSets[2] + 10) / 100,
                                                        unbound_store_change_price[0]))

                return

            if user_vip_level == None:
                self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                           retailSets, ordinary + 1, union, partner, crossStore, bindStoreId,
                                           unboundStoreId, userLevel, purchaseMethod)

            else:
                if user_vip_level[0] == 1:
                    self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                               retailSets, ordinary, union + 1, partner, crossStore, bindStoreId,
                                               unboundStoreId, userLevel, purchaseMethod)

                elif user_vip_level[0] == 2:
                    self.check_members_sharing(referee_user[0], orderId, amount, subRatioList, retailGoodsSkusPrice,
                                               retailSets, ordinary, union, partner + 1, crossStore, bindStoreId,
                                               unboundStoreId, userLevel, purchaseMethod)
                elif user_vip_level[0] == 3:
                    self.retailOrderSharing.session.commit()
                    unbound_store_change_price = self.retailOrderSharing.session.execute(
                        "select rufpr.change_price, rs.user_id\
                                from retail_stores rs\
                                inner join retail_user_frozen_price10_records rufpr on rs.user_id = rufpr.user_id\
                                where rs.id = :unboundStoreId and rufpr.target_id = :targetId limit 1",
                        params={"unboundStoreId": unboundStoreId, "targetId": orderId}).first()
                    print("unbound_store_change_price：", unbound_store_change_price)
                    if unbound_store_change_price[0] != retailGoodsSkusPrice * (retailSets[2] + 10) / 100:
                        print("{}跨店收益计算错误，预期{}，实际{}".format(unbound_store_change_price[1],
                                                            retailGoodsSkusPrice * (retailSets[2] + 10) / 100,
                                                            unbound_store_change_price[0]))

                    self.retailOrderSharing.session.commit()
                    change_price = self.retailOrderSharing.session.execute(
                        "select change_price from retail_user_frozen_price3_records where user_id = :userId and target_id = :targetId limit 1",
                        params={"userId": referee_user[0], "targetId": orderId}).first()
                    if change_price[0] != retailGoodsSkusPrice * (100 - retailSets[2] - 10) / 100:
                        print("{}零售利润计算错误，预期{}，实际{}".format(referee_user[0],
                                                            retailGoodsSkusPrice * (
                                                                    100 - retailSets[2] - 10) / 100,
                                                            change_price[0]))

    # def calculate_the_owner_payment(self, paymentCollection, goodTotal, retail_store_stock_record_list, n):
    #     if goodTotal > retail_store_stock_record_list[n][1]:
    #         paymentCollection += retail_store_stock_record_list[n][2] * retail_store_stock_record_list[n][1]
    #
    #         if goodTotal - retail_store_stock_record_list[n][1] > retail_store_stock_record_list[n + 1][1]:
    #             self.calculate_the_owner_payment(paymentCollection, goodTotal - retail_store_stock_record_list[n][1], retail_store_stock_record_list, n + 1)
    #
    #         else:
    #             paymentCollection += retail_store_stock_record_list[n + 1][2] * (goodTotal - retail_store_stock_record_list[n][1])
    #
    #     else:
    #         paymentCollection += retail_store_stock_record_list[n][2] * goodTotal

    def store_pick_up(self, purchaseMethod):

        userList = []
        if purchaseMethod == 1:
            userList = self.retailOrderSharing.session.execute("select ru.user_id, u.mobile, ua.id, ru.bind_retail_store_id, ru.current_retail_store_id\
                                        from retail_users ru\
                                        inner join user_addresses ua on ru.user_id = ua.user_id\
                                        inner join users u on u.id = ru.user_id\
                                        where ru.is_real_name = 1 and ua.is_default = 1 and ru.user_id = 248692\
                                        and (select count(rgoss.id) from retail_goods_offline_sku_stocks rgoss where rgoss.retail_store_id = ru.bind_retail_store_id and inventory > 0) > 0").fetchall()

        elif purchaseMethod == 3:
            userList = self.retailOrderSharing.session.execute("select ru.user_id, u.mobile, ua.id, ru.bind_retail_store_id, ru.current_retail_store_id\
                                                    from retail_users ru\
                                                    inner join user_addresses ua on ru.user_id = ua.user_id\
                                                    inner join users u on u.id = ru.user_id\
                                                    inner join retail_stores rs on rs.user_id = ru.user_id\
                                                    where ru.is_real_name = 1 and ua.is_default = 1 and rs.is_virtual = 0\
                                                    and ru.user_id in (select rv.user_id from retail_vips rv where rv.vip_level = 3) ").fetchall()

        user = userList[random.randint(0, len(userList) - 1)]
        # user = userList[0]

        vip_level = self.retailOrderSharing.session.execute("select vip_level from retail_vips where user_id = :userId limit 1",
                                         params={"userId": user[0]}).first()
        print("vip_level：", vip_level)

        requests.request("POST", url="https://test.api.vodeshop.com/api/sms/user-login", json={"mobile": user[1]})
        time.sleep(5)

        print("user：", user)
        userToken = requests.request("POST", url="https://test.api.vodeshop.com/api/auth/login/mobile",
                                     json={"mobile": user[1], "password": "", "code": "111111"}).json()
        print("userToken：", userToken)
        self.token = userToken["data"]["token_type"] + " " + userToken["data"]["access_token"]

        goodList = requests.request("GET", url="https://test.api.vodeshop.com/api/retail/mall/index-goods?page=" + str(
            random.randint(1, 4)), headers={"x-request-from": "web", "x-requested-with": "XMLHttpRequest",
                                            "authorization": self.token}).json()["data"]["data"]
        good = goodList[random.randint(0, 14)]
        print("good：", good)

        goodSkuList = requests.request("GET",
                                       url="https://test.api.vodeshop.com/api/retail/goods/show?retail_goods_id=" + str(
                                           good["id"]),
                                       headers={"x-request-from": "web", "x-requested-with": "XMLHttpRequest",
                                                "authorization": self.token}).json()["data"]["goods_skus"]
        if len(goodSkuList) == 1:
            self.goodSku = goodSkuList[0]
        elif len(goodSkuList) > 1:
            self.goodSku = goodList[random.randint(0, random.randint(0, len(goodSkuList) - 1))]
        print("goodSku：", self.goodSku)

        if purchaseMethod == 1:
            good["id"] = 29

        print("goodId：", good["id"])
        goodTotal = random.randint(2, 3)
        orderCheck = requests.request("POST", url="https://test.api.vodeshop.com/api/retail/check-order",
                                      headers={"x-request-from": "web", "x-requested-with": "XMLHttpRequest",
                                               "authorization": self.token},
                                      json={"retail_goods_id": [good["id"]], "address_id": user[2]}).json()
        if purchaseMethod == 1:
            self.goodSku["id"] = 39

        print("goodSku：", self.goodSku["id"])
        confirm = requests.request("POST", url="https://test.api.vodeshop.com/api/retail/order/confirm",
                                   headers={"x-request-from": "web", "x-requested-with": "XMLHttpRequest",
                                            "authorization": self.token},
                                   json={"goods": [{"goods_sku_id": self.goodSku["id"], "goods_total": goodTotal}],
                                         "cart_id": [], "address_id": user[2]}).json()

        # retail_store_stock_record_list = None
        retail_goods_offline_sku_stock = None
        if purchaseMethod == 1:
            # self.retailOrderSharing.session.commit()
            # retail_store_stock_record_list = self.retailOrderSharing.session.execute(
            #     "select id, stock, price from retail_store_stock_records where status = 0 and retail_store_id = :retailStoreId and retail_goods_sku_id = :retailGoodsSkuId order by created_at asc limit " + str(
            #         goodTotal),
            #     params={"retailStoreId": user[4], "retailGoodsSkuId": self.goodSku["id"]}).fetchall()

            self.retailOrderSharing.session.commit()
            retail_goods_offline_sku_stock = self.retailOrderSharing.session.execute(
                "select id, avg_price from retail_goods_offline_sku_stocks where retail_store_id = :retailStoreId and retail_goods_sku_id = :retailGoodsSkuId",
                params={"retailStoreId": user[4], "retailGoodsSkuId": self.goodSku["id"]}).first()

        print("confirm：", confirm)
        order = requests.request("POST", url="https://test.api.vodeshop.com/api/retail/order/order",
                                 headers={"x-request-from": "web", "x-requested-with": "XMLHttpRequest",
                                          "authorization": self.token},
                                 json={"goods": [{"goods_sku_id": self.goodSku["id"], "goods_total": goodTotal}],
                                       "cart_id": [], "address_id": user[2], "pay_type": 1, "purchase_way": purchaseMethod}).json()
        print("order：", order)
        self.retailOrderSharing.session.commit()
        retail_sets = self.retailOrderSharing.session.execute(
            "select credit_ratio, bind_store_ratio, current_store_ratio, agent_ratio from retail_sets limit 1").first()
        goods_sku = confirm["data"]["goods"][0]["items"][0]["goods_sku"]
        amount = 0
        if purchaseMethod == 1:
            amount = (decimal.Decimal(goods_sku["price"]) + decimal.Decimal(
                orderCheck["data"][0]["addr_carriage"])) * goodTotal - decimal.Decimal(confirm["data"]["pickup_sub_price"])
        else:
            amount = (decimal.Decimal(goods_sku["price"]) + decimal.Decimal(
                orderCheck["data"][0]["addr_carriage"]) - decimal.Decimal(goods_sku["sub_price"])) * goodTotal
        print("amount：", amount)
        self.retailOrderSharing.session.commit()
        order_sn = self.retailOrderSharing.session.execute(
            "select order_sn from payments where user_id = :userId and targetable_id =:targetableId order by created_at desc limit 1",
            params={"userId": user[0], "targetableId": order["data"]["order_merge_id"]}).first()
        print("order_sn：", order_sn)

        res = requests.request("POST", url="https://test.api.vodeshop.com/api/v2/test/notifyyyy",
                               data={"out_trade_no": order_sn[0], "trade_no": order_sn[0], "total_amount": "1"}).json()
        print("res：", res)
        time.sleep(10)

        self.retailOrderSharing.session.commit()
        retail_goods_skus = self.retailOrderSharing.session.execute(
            "select price, cost_price, platform_profit_price from retail_goods_skus rgs where id = :skuId limit 1",
            params={"skuId": self.goodSku["id"]}).first()

        subRatioList = []
        for num in range(1, 3):
            self.retailOrderSharing.session.commit()
            sub_ratio = self.retailOrderSharing.session.execute(
                "select sub_ratio from retail_vip_levels where vip_level = :vipLevel limit 1",
                params={"vipLevel": num}).first()
            subRatioList.append(sub_ratio[0])

        crossStore = False
        self.retailOrderSharing.session.commit()
        retail_store_id = self.retailOrderSharing.session.execute(
            "select ro.retail_store_id, rog.id\
                    from retail_orders ro\
                    inner join retail_order_goods rog on rog.retail_order_id = ro.id\
                    where ro.id = :orderId limit 1", params={"orderId": order["data"]["order_id"]}).first()
        if user[3] != retail_store_id[0]:
            crossStore = True

        union, partner = 1, 1
        if vip_level != None:
            proportion = 0

            if vip_level[0] == 1:
                union += 1
                proportion = subRatioList[0]

            elif vip_level[0] == 2:
                partner += 1
                proportion = subRatioList[1]

            elif vip_level[0] == 3:
                if crossStore == False:
                    proportion = 100 - retail_sets[3]
                else:
                    proportion = 100 - retail_sets[3] - retail_sets[2]

            if purchaseMethod == 1:
                if decimal.Decimal(confirm["data"]["pickup_sub_price"]) != (
                        retail_goods_skus[0] - retail_goods_offline_sku_stock[1]) * proportion / 100 * goodTotal:
                    print("{}店铺商品结算页面会员立减错误，预期{}，实际{}".format(good["id"], (
                            retail_goods_skus[0] - retail_goods_offline_sku_stock[1]) * proportion / 100 * goodTotal,
                                                          decimal.Decimal(confirm["data"]["pickup_sub_price"])))

            else:
                if decimal.Decimal(good["sub_price"]) != (
                        retail_goods_skus[0] - retail_goods_skus[1] - retail_goods_skus[2]) * \
                        proportion / 100:
                    print("{}商品列表会员立减错误，预期{}，实际{}".format(good["id"],
                                                          (retail_goods_skus[0] - retail_goods_skus[1] - retail_goods_skus[
                                                              2]) *
                                                          proportion / 100, decimal.Decimal(good["sub_price"])))

                if decimal.Decimal(confirm["data"]["sub_price"]) != (
                        retail_goods_skus[0] - retail_goods_skus[1] - retail_goods_skus[2]) * proportion / 100 * goodTotal:
                    print("{}结算页面会员立减错误，预期{}，实际{}".format(good["id"], (
                            retail_goods_skus[0] - retail_goods_skus[1] - retail_goods_skus[
                        2]) * proportion / 100 * goodTotal,
                                                          decimal.Decimal(confirm["data"]["sub_price"])))

        # print("retail_store_stock_record_list：", retail_store_stock_record_list)

        paymentCollection = decimal.Decimal("0.00")
        if purchaseMethod == 1:
            # if len(retail_store_stock_record_list) == goodTotal:
            #     for retail_store_stock_record in retail_store_stock_record_list:
            #         paymentCollection += retail_store_stock_record[2]

            paymentCollection = retail_goods_offline_sku_stock[1] * goodTotal

            # self.calculate_the_owner_payment(paymentCollection, goodTotal, retail_store_stock_record_list, 0)

        elif purchaseMethod == 3:
            paymentCollection = (retail_goods_skus[1] + retail_goods_skus[2]) * goodTotal

        print("paymentCollection：", paymentCollection)

        self.check_members_sharing(user[0], retail_store_id[1], amount, subRatioList,
                                   amount - paymentCollection,
                                   retail_sets, 1, union, partner, crossStore, user[3], retail_store_id[0], vip_level, purchaseMethod)


if __name__ == "__main__":
    PickUpOrder().store_pick_up(1)
















